<?xml version="1.0" encoding="UTF-8"?>

<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-${liquibase.xsd-version}.xsd">

    <changeSet author="sb" id="add-failed-login-count-and-locked-flag-to-user">
        <addColumn tableName="users">
            <column name="failed_login_count" type="INTEGER" defaultValueNumeric="0"/>
            <column name="is_locked" type="BOOLEAN" defaultValueBoolean="false" />
        </addColumn>
    </changeSet>

    <changeSet author="sb" id="authservice-excessivefailedloginlimit-config">
        <preConditions onFail="CONTINUE" >
            <not>
                <tableExists tableName="authservice_config" />
            </not>
        </preConditions>

        <createTable tableName="authservice_config">
            <column name="excessive_failed_login_limit" type="INTEGER" />
        </createTable>

        <insert tableName="authservice_config">
            <column name="excessive_failed_login_limit" valueNumeric="3" />
        </insert>

    </changeSet>
</databaseChangeLog>
